import java.util.Scanner;


public class Replacer {
	
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		print("Enter a string");
		String str = in.nextLine();
		print("Enter a char to be replaced");
		String rep = in.nextLine();
		print("Enter the char that will be replacing the previous char");
		String toRep = in.nextLine();
		
		str = replace(str, rep, toRep);
		print(str);
	}
	
	public static void print(String str) {
		System.out.println(str);
	}

	public static String replace(String str, String replaceThis, String replaceWith) {
		int location = str.indexOf(replaceThis);
		int len = replaceThis.length();
		if(location != -1) {
			String leftStr = str.substring(0, location);
			String rightStr = str.substring(location + len, str.length());
			str = leftStr + replaceWith + rightStr;			
			return replace(str, replaceThis, replaceWith);
		} else		
		return str;
	}

}
